<template>
	<scroll-view scroll-y="" @scrolltolower="handleData" class="vedio"> 
	<get-userinfo @userClick="showContent" v-if="isCause"> </get-userinfo>
			<view class="vedioTitle">
					<uni-segmented-control 
					:current="current" 
					:values="items.map(v => v.title)" 
					@clickItem="onClickItem" 
					style-type="text" 
					active-color="#d4237a">
					</uni-segmented-control>
					<view class="iconfont icon-search" @click="search"></view>
			</view>
			<view class="vedioContent">
				<view v-if="current< 4">
					<vedio-comment :urlobj="{url:items[current].url,params:items[current].params} "></vedio-comment>
				</view>
				<view v-if="current === 4">
					<vedio-category :url="items[current].url"></vedio-category>
				</view>
			</view>
	</scroll-view>
</template>

<script>
	import {uniSegmentedControl } from '@dcloudio/uni-ui'
	import vedioComment from './vedio-recomment'
	import vedioCategory from './vedio-category'
	import 	getUserinfo  from '../getUserinfo'
	export default {
		components:{
			uniSegmentedControl,
			vedioComment,
			vedioCategory,
			getUserinfo
		},
		data() {
			return {
				items: [
						{
						title:'推荐',
						url:'http://157.122.54.189:9088/videoimg/v1/videowp/featured',
						params:{
							limit:30,
							skip:0,
							order:'hot'
							}
						},
						{
						title:'娱乐',
						url:'http://157.122.54.189:9088/videoimg/v1/videowp/category/59b25abbe7bce76bc834198a',
						params:{
							limit:30,
							skip:0,
							order:'new'
							}
						},
						{
						title:'最新',
						url:'http://157.122.54.189:9088/videoimg/v1/videowp/videowp',
						params:{
							limit:30,
							skip:0,
							order:'new'
							}
						},
						{
						title:'热门',
						url:'http://157.122.54.189:9088/videoimg/v1/videowp/videowp',
						params:{
							limit:30,
							skip:0,
							order:'hot'
							}
						},
						{
						title:'分类',
						url:'http://157.122.54.189:9088/videoimg/v1/videowp/category'
						}
						],
				current: 0,
				isCause:true
			};
		},
		methods:{
			onClickItem(e) {
			   if (this.current !== e.currentIndex) {
				   this.current = e.currentIndex;
				  
			   }
			},
			search(){
				uni.switchTab({ url: '/pages/search/index'});
			},
			// 获取到用户信息后关闭
			showContent(e){
				this.isCause = e
				console.log(e)
			}
		}
	}
</script>

<style lang="scss" scoped>
.vedio{
	.vedioTitle{
			position: relative;
			width:70%;
			margin: 0 auto;
	}
	.icon-search{
		position: absolute;
		top:10px;
		right:-10%;
	}
}
</style>
